{%-set std = resolver.cpp_resolve_namespace(['std']) %}
{%-set rapidjson = resolver.cpp_resolve_namespace(['rapidjson']) %}
{%-set className = resolver.cpp_resolve_namespace(ns)+Name%}
{%-set exception %}{{resolver.cpp_get_lib_ns() | join('::')}}::JsonSchemaException{%endset%}
{{className}}::{{Name}}(bool value)
{
    Set(value);
}

{%-if schema.default is defined %}
{%set emptyConstructor = true %}
{{className}}::{{Name}}()
{
    Set({{schema.default|lower}});
}
{%-endif%}

{{className}}::operator bool() const
{
    return Get();
}

{{className}}& {{className}}::operator=(bool value)
{
    Set(value);
    return *this;
}

void {{className}}::Set(bool value)
{
    _value = value;
}

bool {{className}}::Get() const
{
    return _value;
}

{{className}} {{className}}::FromJson(const {{rapidjson}}Value& json)
{
    if (!(json.IsBool()))
    {
        throw {{exception}}("Not a boolean");
    }

    {{className}} newObject(json.GetBool());
    return newObject;
}

void {{className}}::ToJson({{rapidjson}}Value& value, {{resolver.cpp_resolve_namespace(['rapidjson', 'Value'])}}AllocatorType& allocator) const
{
    value.SetBool(_value); 
}

void {{className}}::SetHandle(const std::string& handle)
{
    _handle = handle;
}

std::string {{className}}::GetHandle() const
{
    return _handle;
}